package com.zhouyihe.weblog.admin.controller;

import com.zhouyihe.weblog.admin.model.vo.tag.AddTagReqVO;
import com.zhouyihe.weblog.admin.model.vo.tag.DeleteTagReqVO;
import com.zhouyihe.weblog.admin.model.vo.tag.FindTagPageListReqVO;
import com.zhouyihe.weblog.admin.model.vo.tag.SearchTagReqVO;
import com.zhouyihe.weblog.admin.service.AdminTagService;
import com.zhouyihe.weblog.common.aspect.ApiOperationLog;
import com.zhouyihe.weblog.common.utils.PageResponse;
import com.zhouyihe.weblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AdminTagController
 * @author: 周益和
 * @qq: 1552951165
 * @date: 2024/6/2
 * @description: 标签模块
 */
@RestController
@RequestMapping("/admin/tag")
@Api(tags = "Admin 标签模块")
public class AdminTagController {
    
     @Autowired
     private AdminTagService tagService;
    
    /**
     * 添加分类
     *
     * @param addTagReqVO 包含新增分类信息的请求体。
     * @return 返回添加分类的操作结果。
     */
    @PostMapping("/add")
    @ApiOperation(value = "添加标签")
    @ApiOperationLog(description = "添加分类")
    public Response addTag(@RequestBody @Validated AddTagReqVO addTagReqVO) {
        return tagService.addTag(addTagReqVO);
    }
    
    /**
     * 获取标签的的分页数据
     *
     * @param findTagPageListReqVO 包含查询条件的请求体。
     * @return 返回分类分页数据。
     */
    @PostMapping("/list")
    @ApiOperation(value = "标签分页数据获取")
    @ApiOperationLog(description = "标签分页数据获取")
    public PageResponse findTagPageList(@RequestBody @Validated FindTagPageListReqVO findTagPageListReqVO) {
        return tagService.findTagPageList(findTagPageListReqVO);
    }

    /**
     * 根据id删除分类
     * @param deleteTagReqVO
     * @return
     */
    @PostMapping("/delete")
    @ApiOperation(value = "删除标签")
    @ApiOperationLog(description = "删除标签")
    public Response deleteCategory(@RequestBody @Validated DeleteTagReqVO deleteTagReqVO) {
        return tagService.deleteTag(deleteTagReqVO);
    }

    /**
     * 标签模糊查询
     * @return
     */
    @PostMapping("/search")
    @ApiOperation(value = "标签模糊查询")
    @ApiOperationLog(description = "标签模糊查询")
    public Response SearchTag(@RequestBody @Validated SearchTagReqVO searchTagReqVO) {
        return tagService.SearchTag(searchTagReqVO);
    }
    
    @PostMapping("/select/list")
    @ApiOperation(value = "查询标签 Select 列表数据")
    @ApiOperationLog(description = "查询标签 Select 列表数据")
    public Response findTagSelectList() {
        return tagService.findTagSelectList();
    }
}
